package pro.softzhang.algo.lc2400;

import pro.softzhang.algo.flag.x.XOptimal;

/**
 *
 */
public class LC2432_TheEmployeeThatWorkedOnTheLongestTask {
    public static void main(String[] args) {

    }

    /**
     *
     */
    @XOptimal
    static
    class Solution {
        public int hardestWorker(int n, int[][] logs) {
            int worker = logs[0][0], maxTime = logs[0][1];
            for (int i = 1; i < logs.length; i++) {
                int time = logs[i][1] - logs[i-1][1];
                if(time > maxTime || time == maxTime && worker > logs[i][0]) {
                    worker = logs[i][0];
                    maxTime = time;
                }
            }
            return worker;
        }
    }
}
